package com.ibiaoke.boss.controller;

import com.ibiaoke.boss.entity.SysUser;
import com.ibiaoke.common.base.BaseController;
import com.ibiaoke.common.base.Page;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.goods.entity.ReserveGoods;
import com.ibiaoke.goods.service.ReserveGoodsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

@Controller
public class BossReserveGoodsController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(this.getClass().getName());

    @Autowired
    private ReserveGoodsService reserveGoodsService;

    @RequestMapping("/addReserveGoods")
    @ResponseBody
    public Res addStock(ReserveGoods reserveGoods, Integer shopId){
        SysUser user = getLoginUser();
        reserveGoodsService.addReserveGoods(user.getUserName(),shopId,reserveGoods);
        logger.info("系统用户{}正在添加订货操作",user.getUserName());
        return Res.create();
    }


    @RequestMapping("/findReserveGoodsList")
    @ResponseBody
    public Res findStock(String goodName, Integer goodId, Date reserveStartTime,Date reserveEndTime, Integer shopId, Page page) {
        List<ReserveGoods> reserveGoodsList =  reserveGoodsService.findGoodStockList(goodName,goodId,reserveStartTime,reserveEndTime,shopId,page);
        return Res.create().addResponse("reserveGoodsList", reserveGoodsList).addResponse("page",page);
    }

}
